package com.fizzkai.p2p.mgrsite.controller;

import com.fizzkai.p2p.core.domain.VideoAuth;
import com.fizzkai.p2p.core.query.VideoAuthQuery;
import com.fizzkai.p2p.core.service.IVideoAuthService;
import com.fizzkai.p2p.core.util.AjaxResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;

@Controller
public class VideoAuthController {

    @Autowired
    private IVideoAuthService videoAuthService;


    /**
     * 审核 列表页面
     * @param qo
     * @param model
     * @return
     */
    @RequestMapping("/videoAuth")
    public String videoAuth(@ModelAttribute("qo") VideoAuthQuery qo, Model model){
        PageInfo<VideoAuth> pageInfo = videoAuthService.query(qo);
        model.addAttribute("pageInfo", pageInfo);
        return "videoAuth/list";
    }

    /**
     * 审核 / 拒审 请求
     * @return
     */
    @RequestMapping("/videoAuth_audit")
    @ResponseBody
    public Object videoAuth_audit(Integer state, Long videoAuthId, String remark){
        videoAuthService.audit(videoAuthId, state, remark);
        return new AjaxResult(state == VideoAuth.STATE_PASS ? "审核通过成功" : "拒审成功");
    }
    
    @RequestMapping("/listUserByAutoComplate")
    @ResponseBody
    public Object listUserByAutoComplate(String username){
        ArrayList<String> list = new ArrayList<>();
        list.add(username + "一号");
        list.add("二号" + username);
        list.add(username + "三号");
        list.add("四号" + username);
        list.add(username + "五号");
        return list;
    }
}
